﻿<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="SocialFeed.HubPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SocialFeed"
    xmlns:data="using:SocialFeed.Data"
    xmlns:common="using:SocialFeed.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Page.Resources>

        <!--
            Collection of grouped items displayed by this page, bound to a subset
            of the complete item list because items in groups cannot be virtualized
        -->
        <CollectionViewSource
            x:Name="groupedItemsViewSource"
            Source="{Binding Groups}"
            IsSourceGrouped="true"
            ItemsPath="TopItems"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:HubPageDataSource, IsDesignTimeCreatable=True}}"/>

        <CollectionViewSource
            x:Name="groupedItemsViewSource2"
            Source="{Binding Groups2}"
            IsSourceGrouped="true"
            ItemsPath="TopItems"
            d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:RecentDataSource, IsDesignTimeCreatable=True}}"/>

        <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
        <x:String x:Key="AppName">My Application</x:String>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines two rows:
        * Row 0 contains the back button and page title
        * Row 1 contains the rest of the page layout
    -->
    <Grid Style="{StaticResource LayoutRootStyle}">
        <Grid.Background>
            <ImageBrush ImageSource="Assets/Background.jpg" Stretch="UniformToFill"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="100"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!-- Horizontal scrolling grid used in most view states -->
        
        <ScrollViewer x:Name="MainScroll" Style="{StaticResource HorizontalScrollViewerStyle}" Grid.Row="1">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="120"/>
                    <ColumnDefinition Width="485"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
        		
        			<StackPanel Grid.Column="1" Orientation="Vertical">
                    <TextBlock Text="post" FontSize="42" Foreground="#FF7ebec9" FontWeight="SemiBold"  Margin="3,0,10,30" Style="{StaticResource GroupHeaderTextStyle}"/>
                    <Grid Height="150" VerticalAlignment="Top">
            			<Grid.ColumnDefinitions>
            				<ColumnDefinition/>
            				<ColumnDefinition Width="150"/>
            			</Grid.ColumnDefinitions>
            			<Grid.RowDefinitions>
            				<RowDefinition/>
            				<RowDefinition/>
            			</Grid.RowDefinitions>
            			<Path Grid.ColumnSpan="2" Data="M36.5,0.5 L408.807,0.5 L409.175,0.520852 L410,0.5 C451.145,0.500001 484.5,33.8548 484.5,75 C484.5,116.145 451.145,149.5 410,149.5 C368.855,149.5 335.5,116.145 335.5,75 L335.513,74.5 L36.5,74.5 C16.6177,74.5 0.5,58.3823 0.5,38.5 L0.5,36.5 C0.5,16.6177 16.6177,0.499999 36.5,0.5 z" Fill="#FFF4F4F5" Grid.RowSpan="2" Stretch="Fill" UseLayoutRounding="False"/>
            			<Button Content="submit" Click="Submit_Clicked" Grid.Column="1" Margin="10" Grid.RowSpan="2" Style="{StaticResource SubmitStatusBtnStyle}" VerticalAlignment="Bottom"/>
            			<StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="10,0">
            				<Button Tag="{StaticResource FaceBook}" Foreground="#FF3b5998" Height="50" Margin="10,0" Style="{StaticResource SocialBtnStyle}" Width="50"/>
            				<Button Tag="{StaticResource Twitter}" Foreground="#FF4099ff" Height="50" Margin="10,0" Style="{StaticResource SocialBtnStyle}" Width="50"/>
            				<Button Tag="{StaticResource LinkedIn}" Foreground="#FF006695" Height="50" Margin="10,0" Style="{StaticResource SocialBtnStyle}" Width="50"/>

            			</StackPanel>
            			<TextBox TextWrapping="Wrap" Text="what’s on your mind?" Background="{x:Null}" BorderBrush="{x:Null}" Margin="10,0,30,0" FontSize="26.667" Padding="10,0" FontWeight="Light" Foreground="#FF796064" Grid.ColumnSpan="2" VerticalAlignment="Center"/>
        		
            		</Grid>

                    <ListView
            x:Name="itemListView2"
            AutomationProperties.AutomationId="ItemListView2"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Padding="0,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource2}}"
            ItemTemplate="{StaticResource RecentItemsTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false" ItemContainerStyle="{StaticResource ListViewItemContainerStyle}" Margin="0,20,0,0">

                        <ListView.GroupStyle>
                            <GroupStyle>
                                <GroupStyle.HeaderTemplate>
                                    <DataTemplate>
                                        <Grid Margin="7,7,0,0">
                                            <Button Foreground="#FF7ebec9"
                                    AutomationProperties.Name="Group Title"
                                    Style="{StaticResource TextPrimaryButtonStyle}">
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Title}" FontSize="32" FontWeight="SemiBold"  Margin="0,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}"/>
                                                    <!--<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>-->
                                                </StackPanel>
                                            </Button>
                                        </Grid>
                                    </DataTemplate>
                                </GroupStyle.HeaderTemplate>
                            </GroupStyle>
                        </ListView.GroupStyle>
                    </ListView>

                  
                </StackPanel>
        		
        			<GridView
        				x:Name="itemGridView"
        				AutomationProperties.AutomationId="ItemGridView"
        				AutomationProperties.Name="Grouped Items"
        				Grid.Column="2"
        				Padding="80,0,40,0"
        				ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
        				ItemTemplate="{StaticResource NormalTemplate}"
        				SelectionMode="None" IsItemClickEnabled="True" ItemClick="itemGridView_ItemClick_1"
        				IsSwipeEnabled="false" ItemContainerStyle="{StaticResource GridViewItemContainerStyle}">

        				<GridView.ItemsPanel>
        					<ItemsPanelTemplate>
        						<VirtualizingStackPanel Orientation="Horizontal" Margin="0,0,80,0"/>
        					</ItemsPanelTemplate>
        				</GridView.ItemsPanel>
        				<GridView.GroupStyle>
        					<GroupStyle>
        						<GroupStyle.HeaderTemplate>
        							<DataTemplate>
        								<Grid Margin="1,10,0,6">
        									<Button Foreground="#FF7ebec9" Tag="{Binding UniqueId}" Click="Header_Clicked"
        										AutomationProperties.Name="Group Title"
        										Style="{StaticResource TextPrimaryButtonStyle}">
        										<StackPanel Orientation="Horizontal">
        											<TextBlock Text="{Binding Title}" FontSize="42" FontWeight="SemiBold"  Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}"/>
        											<!--<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>-->
        		
        										</StackPanel>
        									</Button>
        								</Grid>
        							</DataTemplate>
        						</GroupStyle.HeaderTemplate>
        						<GroupStyle.Panel>
        							<ItemsPanelTemplate>
        								<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
        							</ItemsPanelTemplate>
        						</GroupStyle.Panel>
        					</GroupStyle>
        				</GridView.GroupStyle>
        			</GridView>
        		
        	</Grid>
        </ScrollViewer>
        

        <!-- Vertical scrolling list only used when snapped -->
        <ListView
            x:Name="itemListView"
            AutomationProperties.AutomationId="ItemListView"
            AutomationProperties.Name="Grouped Items"
            Grid.Row="1"
            Visibility="Collapsed"
            Margin="0,-10,0,0"
            Padding="10,0,0,60"
            ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
            ItemTemplate="{StaticResource Standard80ItemTemplate}"
            SelectionMode="None"
            IsSwipeEnabled="false">

            <ListView.GroupStyle>
                <GroupStyle>
                    <GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <Grid Margin="7,7,0,0">
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
                                    </StackPanel>
                            </Grid>
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>
                </GroupStyle>
            </ListView.GroupStyle>
        </ListView>

        <!-- Back button and page title -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
            <TextBlock x:Name="pageTitle" Text="Your App Title Goes Here" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
            <Image x:Name="logo" Source="Assets/AppLogo.png" Grid.Column="1" HorizontalAlignment="Right" Height="70" Margin="10"/>
            
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>

                <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                <VisualState x:Name="FullScreenPortrait">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="logo" Storyboard.TargetProperty="HorizontalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="logo" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>

                <!--
                    The back button and title have different styles when snapped, and the list representation is substituted
                    for the grid displayed in all other view states
                -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                        </ObjectAnimationUsingKeyFrames>                      
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainScroll" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="logo" Storyboard.TargetProperty="HorizontalAlignment">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Left"/>
                        </ObjectAnimationUsingKeyFrames>

                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="logo" Storyboard.TargetProperty="Margin">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
                        </ObjectAnimationUsingKeyFrames>


                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>
